
<!DOCTYPE html>
<html class="x-admin-sm">
{include file="common/static" /}

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">

            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>房型</label>
                <div class="layui-input-inline">
                    <input type="text" name="building" required=""
                           lay-verify="building" autocomplete="off" class="layui-input" placeholder="请输入房型" value="{$list.type_name}" id="type_name">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>价格
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="price" name="username" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" value="{$list.price}">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>押金
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="deposit" name="username" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" value="{$list.deposit}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>类型</label>
                <div class="layui-input-inline">
                    <select name="shipping" class="valid" id="type">

                        {switch list.types}
                        {case 1}<option value="1">全天房</option>{/case}
                        {case 2} <option value="2">钟点1小时</option>{/case}
                        {case 3} <option value="3">钟点2小时</option>{/case}
                        {case 4} <option value="4">钟点3小时</option>{/case}
                        {case 5} <option value="5">钟点4小时</option>{/case}
                        {default /}default
                        {/switch}
                        <option value="1">全天房</option>
                        <option value="2">钟点1小时</option>
                        <option value="3">钟点2小时</option>
                        <option value="4">钟点3小时</option>
                        <option value="5">钟点4小时</option>

                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" type="button" onclick="edits({$list.id})">增加</button></div>
        </form>
    </div>
</div>

</body>
<script>
    layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                        layer = layui.layer;
            });

    function edits(id){
        $.ajax({
            type:"post",
            url: "{:url('index/layouts/edits')}",
            data: {
                id:id,
                type_name:$('#type_name').val(),
                price:$('#price').val(),
                deposit:$('#deposit').val(),
                types:$('#type').val(),
            },
            success: function(data){
                console.log(data);
                toastr.error(data.msg);
                if(data.code == 100){
                    setTimeout(function () {
                        layer.closeAll();
                        parent.location.reload();
                    },1500);
                }
            }});
    }
</script>
</html>
